<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0); 
%>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
<META HTTP-EQUIV="Expires" CONTENT="0">
<script type="text/javascript">
	var currentMenuName="${currentMenuName}";
	var totalPath="<%=path %>";
</script>
<jsp:include page="script.jsp" />
<script type="text/javascript">
	t=(new Date()).valueOf();
	var jefActionTable = null;
	//声明xbox对象
	var xbox=new BlackBox();
	
	$(function(){
			if($("#gridHead").size()>0)
				$("#gridHead").jefActionRow({key:'${currentMenuId}',afterInit:function(control){jefActionTable=control}});
			$(".info_right_tab td").css({"border":"none"});
			$(".info_right_tab table #btnSearch").css({"margin-left":"22px"});
			var url=window.top.location;
			var index =url.toString().indexOf("&");
			//if(index!=-1){
			//	window.location.href="<%=path%>/";
			//}
			$(".controls input[id]").change(function(){
				
			});
			
			$(document.body).find(":text:not(.Wdate)").bind("keydown",
					//绑定查询事件,在文本上按回车执行查询,查询按钮ID必须为btnSearch
					function (event){
					event.stopPropagation();
					if(event.keyCode==13){
						event.preventDefault();
						if($("#saveForm").size()!=0){
							var inputs = $( "#saveForm" ) .find ( ":text" ) ; //获取表单中的所有输入框 
							var idx = inputs.index ( this ) ; //获取当前焦点输入框所处的位置 
							if ( idx == inputs.length - 1 ) // 判断是否是最后一个输入框 
							{ 
								if(typeof(save)=='function'){
									$(this).blur();
									save();
								}
							}else{
								inputs[ idx + 1 ] .focus ( ) ; //设置焦点 
								inputs[ idx + 1 ] .select ( ) ; //选中文字 
							} 
						}
						else if($("#btnSearch").attr("id")){
							$(this).trigger("blur");
							j_search(1);//$("#btnSearch").trigger("click");
							$(this).trigger("focus");	
						}
					}
				});
			
			if($("#gridHead").size()>0){
				//加载数据
				var initPage = $("#currentPage").val();
				j_search(initPage =="" ? 1 : parseInt(initPage));
				$("#refreshForm :text").attr("autocomplete","off");
			}
	});
	
	function addError(objId,message,notFocus){
		if((typeof objId)=="object"){
			layer.tips(message , objId, 3, 400, 0, ['background-color:#F26C4F; color:#fff;','#F26C4F']);
			if(typeof(notFocus)=="undefined"){
				objId.focus();
			}else{
				j_tip(message,"error");
			}
		}else if((typeof objId)=="string"){
			layer.tips(message , $("#"+objId), 3, 400, 0, ['background-color:#F26C4F; color:#fff;','#F26C4F']);
			if(typeof(notFocus)=="undefined")
				$("#"+objId).focus();
			else{
				j_tip(message,"error");
			}
		}else{
			alert("ERROR");
		}
	}
	function putError(control,message){
		layer.tips(message , control, 3, 400, 0, ['background-color:#F26C4F; color:#fff;','#F26C4F']);
		control.focus();
	}
	function addTip(control,message){
		control.attr("title",message).css("border","solid red 1px");
	}
	
	//通用TIP提示方法
	function j_tip(message,type,title,position,method){
		if(position!= undefined || position!=null){
			toastr.options = {
					  "closeButton": false,
					  "debug": false,
					  "positionClass": "toast-top-right",
					  "onclick": method,
					  "showDuration": "300",
					  "hideDuration": "1000",
					  "timeOut": "5000",
					  "extendedTimeOut": "1000",
					  "showEasing": "swing",
					  "hideEasing": "linear",
					  "showMethod": "fadeIn",
					  "hideMethod": "fadeOut"
					}
			toastr.info(message,title);
		}else{
			if(type== undefined || type==null){
				toastr.info(message);
			}else if(type=="error"){
				toastr.error(message);
			}else if(type=="success"){
				toastr.success(message);
			}else if(type=="warning"){
				toastr.warning(message);
			}else{
				toastr.info(message);
			}
		}
		
	}
	
	function addWarning(css,message){
		layer.tips(message , $("#"+objId), 3, 400, 1, ['background-color:#F26C4F; color:#fff;','#F26C4F']);
		$("#"+objId).focus();
	}
	/**
	 * 短信息快速回复
	 * @param {Object} replyUserId 回复用户ID
	 */
	function quickReply(replyUserId,replyRealName){
		 layer.prompt({type: 3, title: '回复:'+replyRealName}, function(val){
				 $.ajax({
						url			:"<%=path%>/message/messageAjax_save_msgAction.action",
						type 		: "POST",
						dataType 	: "json",
						data		: {
							"receiverIdStr" : replyUserId+",",
							"message.messageContent" : val
						},
						success 	: function(msg) {
							j_tip(msg);
						},
						error		:function(){
							j_tip("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
						}
				});
			});
	}
	
	function openHistoryMenu(menuId,menuUrl){
		$("#frameHistoryAjax").attr("src","<%=path%>"+menuUrl+"?currentMenuId="+menuId);
		$("#divHistoryAjax").slideDown(1000);
	}
	
	function operationManual(menuId){
		var widthVal=$(document.body).width()-100;
		var heightVal=$(document.body).height()-100;
		$.layer({
		    type : 2,
		    title : '帮助',
		    iframe : {src : "<%=path%>/menu/menu_toEdit_helpAction.action?menuId="+menuId},
		    area : [widthVal , heightVal],
		    offset : ['20px',''],
		    end : function(){
		    }
		});
	}
	
	function openSearchBox(url){
		var widthVal=$(document.body).width()-100;
		var heightVal=$(document.body).height()-100;
		$.layer({
		    type : 2,
		    title : '高级检索',
		    iframe : {src : url},
		    area : [widthVal , heightVal],
		    offset : ['20px',''],
		    end : function(){
		    }
		});
	}
	
	function openModelWindow(title,url,width,height){
		var widthVal=width ? width : $(document.body).width()-100;
		var heightVal=height ? height : $(document.body).height()-100;
		$.layer({
		    type : 2,
		    title : title,
		    iframe : {src : url},
		    area : [widthVal , heightVal],
		    offset : ['20px',''],
		    end : function(){
		    }
		});
	}
	
	function closeSearchBox(){
		$(".xubox_close").click();
	}
	
	function j_search(page,reset){
		var refreshForm = $("#refreshForm");
		if(reset){
			$("input[name]:not(:hidden),select[name]",refreshForm).val("");
		}else if (!checkForm(document.getElementById("refreshForm"))) {
			return;
		}
		$("input[name],select[name]",refreshForm).each(function(){
			var value = $(this).val();
			if(value!="")
				refreshForm.data($(this).attr("name"),value);
			else
				refreshForm.removeData($(this).attr("name"));
		});
		j_loadData(page,true);
	}
	
	function j_goUrl(url,page){
		xbox.load("loading");
		var refreshForm = $("#refreshForm");
		var search = "?currentMenuId=${currentMenuId}";
		$("input[name],select[name]",refreshForm).each(function(){
			var value = refreshForm.data($(this).attr("name"));
			if(typeof(value) != "undefined"){
				$(this).val(value);
				search+="&"+$(this).attr("name")+"="+value;			
			}
		});
		refreshForm.append('<input type="hidden" name="currentMenuId" value="${currentMenuId}"/>'
		+'<input type="hidden" name="listUrl" value="'+refreshForm.attr("action")+search+'"/>'
		).attr("action",url).submit();
	}
	
	function j_loadData(page,notScroll){
		var refreshForm = $("#refreshForm");
		refreshForm.data("currentPage",page);
		var search = '';
		$("input[name],select[name]",refreshForm).each(function(){
			var value = refreshForm.data($(this).attr("name"));
			if(typeof(value) != "undefined")
				search+=','+$(this).attr("name")+':"'+value+'"';
		});
		var params = eval('[{loadData:1,currentMenuId:${currentMenuId}'+search+'}]');
		xbox.load("loading");
		var divGrid = $("#divGrid");
		var scrollLeft = 0;
		if(typeof (notScroll)== "undefined")
			scrollLeft = divGrid.scrollLeft();
		//执行查询
		divGrid.load(refreshForm.attr("action"),params[0],
			function(){
				xbox.ready("loading");
				if(jefActionTable!=null)
					jefActionTable.initGrid();
				if(scrollLeft!=0)
					divGrid.scrollLeft(scrollLeft);
			}
		);
	}
	
	function j_closeWin(){
		$("#w_cover,#w_window").remove();
	}
	
	function j_window(options){
		var w_width = options.width ? options.width : 400;
		var w_height = options.height ? options.height : 200;
		var width = $(window).width();
		var height = $(window).height();
		var w_body = $("body:first");
		if(w_body.width()>width)
			width=w_body.width();
		if(w_body.height()>height)
			height=w_body.height();
		w_body.append("<div id='w_cover' style='background-color: black; position: absolute; z-index: 9990; filter: Alpha(opacity=20); opacity: 0.2; left: 0px; top: 0px;width:"+width+"px;height:"+height+"px'>透明层</div><div id='w_window' style='position: absolute;  z-index: 9999;text-align: center;width:"+w_width+"px;height:"+w_height+"px;border:solid gray 5px;background-color:white;top:75px;left:"+((width-w_width)/2)+"px'><div style='width:100%;height:"+(w_height-55)+"px'>"+options.html+"</div><div style='padding:10px;border-top:solid gray 1px;'><input type='button' id='w_btnSave' class='btn btn-primary' value='保存'/><input type='button' class='btn' value='返回' onclick='j_closeWin();'/></div></div>")
		$("#w_btnSave").click(function(){
			if(typeof(options.callBack)=="function"){
				options.callBack();
			}
			j_closeWin();
		});
	}
</script>

<script type="text/javascript">
/*
setInterval(function(){
	$.ajax({
				url			:"<%=path%>/message/messageAjax_listenMessage_messageAction.action",
				type 		: "POST",
				dataType 	: "json",
				data		: {
					"userId" : "${sessionScope.sessionUser.userId}"
				},
				success 	: function(msg) {
					if(msg!=null){
						$.ajax({
							url			:"<%=path%>/message/messageAjax_updateMessageTip_msgAction.action",
							type 		: "POST",
							dataType 	: "json",
							data		: {
								"messageId" : msg.messageId
							},
							success 	: function(data) {
								j_tip(msg.messageContent,"info","来自:"+msg.sender.realName,"topRight",function(){
									quickReply(msg.sender.userId,msg.sender.realName);
								});
							},
							error		:function(){
								j_tip("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
							}
						});
					}
				},
				error		:function(){
					
				}
		});
},5000);
*/
</script>

<style>
#gridTable,#gridHead{
	display: none;
	TABLE-LAYOUT:fixed;
}
</style>